<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="sm-crypto.min.js"></script>
    <script src="secure-sm.js"></script>
</head>
<body>
<button onclick="startPost()">发起</button>

<script>
    // 正式使用不要公开此实例
    const secure = new Secure({
        secureServer: "/test/test",
        disguise: "img"
    });
    secure.exchange();

    async function startPost() {
        const enjson = secure.encrypt({
            a: "str",
            b: 123,
            c: ["1", 2, 3]
        }, ["a", "b", "c"]);
        fetch("/test/post", {
            method: "POST",
            body: JSON.stringify(enjson),
            headers: {
                "content-type": "application/json"
            }
        }).then(res => res.text()).then(text => {
            console.log(text.decrypt());
        });
        console.log(secure);
    }
</script>
</body>
</html>